﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using Facebook.Schema;
using PivotCollectionTools.BasicCollection;

namespace test_app
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WindowWidth = 120;
            // this is the xml dump of all your facebook friends created in the Pivot Collection Builder Demo
            // that demo can be found here http://www.anythingtheycando.com/blog/index.php/2009/12/03/facebook-friends-collection-builder/
            // that will allow you to download just download friends and then use the xml output with this app. 
            TextReader tr = new StreamReader("../../../FacebookFriends.xml");
            XmlSerializer s = new XmlSerializer(typeof(List<user>));
            var data = s.Deserialize(tr) as List<user>;
            
            
            PivotCollectionTools.BasicCollection.PivotCollection<FacebookUser> friends = new PivotCollection<FacebookUser>();
            // this turns on item image caching ie if two items link to the same image then it will only run it through the deep zoom composer once 
            friends.AllImagesUnique = false;
            // name to display for the collection (shows up in pivot
            friends.CollectionName = "Facebook Friends";
            
            friends.SupressActionChanged = false;
            // output each step to the console
            friends.ActionChanged += new EventHandler(friends_ActionChanged);

            foreach (user friend in data)
            {
                friends.Items.Add(new FacebookUser(friend));
            }
            // lets build the collection 
            friends.WriteCollectionToFileSystem("../../../TestAttributes.cxml");
            
        }

        static void friends_ActionChanged(object sender, EventArgs e)
        {
            Console.WriteLine(sender.ToString());
        }
    }
}
